#include<cstdio>
#include<algorithm>
#include<iostream>
#include<set>
#define openfile(s) freopen(s".in","r",stdin);freopen(s".out","w",stdout)
using namespace std;
const int N=2e3+1;
const long long MOD=998244353;
int n;
string s;
bool check()
{
	for(int i=1;i<n;i++)
		if(s[i]==s[i+1])
			return false;
	return true;
}
struct Cmp
{
	bool operator()(const string& a,const string& b)const
	{
		return a.length()!=b.length()?a.length()>b.length():a<b;
	}
};
void work()
{
	cin>>s;
	n=s.length();
	if(check()){
		int ans=1;
		for(int i=1;i<n;i++) ans+=(s[i]=='A');
		printf("%d",ans);
		return;
	}
	set<string,Cmp> vis,wai;
	wai.insert(s);
	for(;wai.size();){
		string str=*wai.begin();
		wai.erase(wai.begin());
		if(vis.count(str)) continue;
		vis.insert(str);
		for(int i=0;i+1<str.length();i++){
			if((str[i]==str[i+1] && (i==0 || str[i]!=str[i-1])) || (str[i]=='B' && str[i+1]=='A')){
				string ts=str;
				wai.insert(ts.erase(i,2));
			}
		}
	}
	printf("%llu",vis.size());
	return;
}
int main()
{
	freopen("input.in","r",stdin);
//	freopen("output.out","w",stdout);
	openfile("song");
	work();
	return 0;
}
